//************************************************************
//  Copyright (c)   
//	FileName	   : SC_Init.c
//	Function	   : Contains the MCU initialization function and its C file
//  Instructions   : 
//*************************************************************

#include "SC_Init.h"	// MCU initialization header file, including all firmware library header files
#include "..\Drivers\SCDriver_list.h"

//*************************************************************
/**************************************Generated by EasyCodeCube*************************************/
//Forbid editing areas between the labels !!!
/*************************************.Generated by EasyCodeCube.************************************/
/*****************************************************
*????????: SC_Init
*????????: MCU?????????
*????????void
*?????????void
*****************************************************/
void SC_Init(void)
{
	//Forbid editing areas before the following label !!!
	SC_GPIO_Init();
	SC_OPTION_Init();
	SC_USCI0_Init();
	SC_USCI1_Init();
	SC_USCI2_Init();
	SC_TIM0_Init();
	//SC_TIM1_Init();
	SC_PWM0_Init();
	SC_PWM2_Init();
	SC_BTM_Init();
//	SC_WDT_Init();
//	SC_PWR_Init();
	/*write initial function here*/	
	EA = 1;	
}

/*****************************************************
*????????: SC_OPTION_Init
*????????: OPTION???��????????
*????????void
*?????????void
*****************************************************/
void SC_OPTION_Init(void)
{
	//Forbid editing areas before the following label !!!
	SC95F8765_NIO_Init();
	/*OPTION_Init write here*/		
}

/*****************************************************
*????????: SC_GPIO_Init
*????????: GPIO?????????
*????????void
*?????????void
*****************************************************/
void SC_GPIO_Init(void)
{
	//Forbid editing areas before the following label !!!
	GPIO_Init(GPIO3, GPIO_PIN_3, GPIO_MODE_OUT_PP);
	
	GPIO_Init(GPIO3, GPIO_PIN_2, GPIO_MODE_OUT_PP);
    GPIO_Init(GPIO3, GPIO_PIN_1, GPIO_MODE_OUT_PP);
    GPIO_Init(GPIO3, GPIO_PIN_0, GPIO_MODE_OUT_PP);
    GPIO_Init(GPIO1, GPIO_PIN_0, GPIO_MODE_OUT_PP);

	GPIO_Init(GPIO2, GPIO_PIN_3, GPIO_MODE_OUT_PP);

	
	GPIO_Init(GPIO1, GPIO_PIN_2, GPIO_MODE_OUT_PP);
	
	GPIO_Init(GPIO0, GPIO_PIN_4, GPIO_MODE_OUT_PP);
	
	//GPIO_Init(GPIO1, GPIO_PIN_1, GPIO_MODE_OUT_PP);

	GPIO_Init(GPIO2, GPIO_PIN_7, GPIO_MODE_OUT_PP);
	P04 = 1;
	/*GPIO_Init write here*/		
}

/*****************************************************
*????????: SC_UART0_Init
*????????: UART0?????????
*????????void
*?????????void
*****************************************************/
void SC_UART0_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*UART0_Init write here*/		
}

/*****************************************************
*????????: SC_TIM0_Init
*????????: TIMER0?????????
*????????void
*?????????void 
*****************************************************/
void SC_TIM0_Init(void)
{
	//Forbid editing areas before the following label !!!
	TIM0_TimeBaseInit(TIM0_PRESSEL_FSYS_D1,TIM0_MODE_TIMER);
	TIM0_WorkModeConfig(TIM0_WORK_MODE1,33536, 0);
	TIM0_ITConfig(ENABLE,HIGH);
	TIM0_Cmd(ENABLE);
	/*TIM0_Init write here*/		
}

/*****************************************************
*????????: SC_TIM1_Init
*????????: TIMER1?????????
*????????void
*?????????void
*****************************************************/

void SC_TIM1_Init(void)
{
	//Forbid editing areas before the following label !!!
	TIM1_TimeBaseInit(TIM1_PRESSEL_FSYS_D1,TIM1_MODE_TIMER);
	TIM1_WorkModeConfig(TIM1_WORK_MODE1,62336);
	TIM1_ITConfig(ENABLE,LOW);
	TIM1_Cmd(ENABLE);
}

/*****************************************************
*????????: SC_TIM2_Init
*????????: TIMER2?????????
*????????void
*?????????void
*****************************************************/
void SC_TIM2_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*TIM2_Init write here*/	
}

/*****************************************************
*????????: SC_TIM3_Init
*????????: TIMER3?????????
*????????void
*?????????void
*****************************************************/
void SC_TIM3_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*TIM3_Init write here*/	
}

/*****************************************************
*????????: SC_TIM4_Init
*????????: TIMER4?????????
*????????void
*?????????void
*****************************************************/
void SC_TIM4_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*TIM4_Init write here*/	
}

/*****************************************************
*????????: SC_PWM_Init
*????????: PWM?????????
*????????void
*?????????void 
*****************************************************/
void SC_PWM_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PWM_Init write here*/	
}

/*****************************************************
*????????: SC_PWM0_Init
*????????: PWM0?????????
*????????void
*?????????void 
*****************************************************/
void SC_PWM0_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PWM0??????*/PWM_Init(PWM0_PRESSEL_FHRC_D1,PWM0_VALUE_MAX -1);
	/*PWM04 ??????*/PWM_IndependentModeConfigEX(PWM04,0, PWM_OUTPUTSTATE_ENABLE);
	/*PWM05 ??????*/PWM_IndependentModeConfigEX(PWM05,0, PWM_OUTPUTSTATE_ENABLE);
	/*PWM06 ??????*/PWM_IndependentModeConfigEX(PWM06,0, PWM_OUTPUTSTATE_ENABLE);
	/*PWM07 ??????*/PWM_IndependentModeConfigEX(PWM07,0, PWM_OUTPUTSTATE_ENABLE);
	/*PWM0*/PWM_Aligned_Mode_Select(PWM0_Edge_Aligned_Mode);
	/*PWM0*/PWM_FaultDetectionConfigEX(PWM0_Type,DISABLE);
	/*PWM0*/PWM_FaultDetectionModeConfigEX(PWM0_Type,PWM0_Immediate_Mode,PWM0_FaultDetectionVoltage_Low,PWM0_WaveFilteringTime_0us);
	/*PWM0?��????*/PWM_ITConfigEX(PWM0_Type,DISABLE,LOW);
	/*PWM0????*/PWM_CmdEX(PWM0_Type,ENABLE);
	/*PWM0_Init write here*/	
	
}

/*****************************************************
*????????: SC_PWM1_Init
*????????: PWM1?????????
*????????void
*?????????void 
*****************************************************/
void SC_PWM1_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PWM1_Init write here*/	
}

/*****************************************************
*????????: SC_PWM2_Init
*????????: PWM1?????????
*????????void
*?????????void 
*****************************************************/
void SC_PWM2_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PWM2��ʼ��*/PWM_Init(PWM2_PRESSEL_FHRC_D1,PWM2_VALUE_MAX-1);
	/*PWM20 ����ģʽ*/PWM_IndependentModeConfigEX(PWM20, 0x00 ,PWM_OUTPUTSTATE_ENABLE);
	/*PWM2�ж�ʹ��*/PWM_ITConfigEX(PWM2_Type,DISABLE,LOW);
	/*PWM2����*/PWM_CmdEX(PWM2_Type,ENABLE);
}

/*****************************************************
*????????: SC_PWM3_Init
*????????: PWM1?????????
*????????void
*?????????void 
*****************************************************/
void SC_PWM3_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PWM3_Init write here*/	
}

/*****************************************************
*????????: SC_PWM4_Init
*????????: PWM1?????????
*????????void
*?????????void 
*****************************************************/
void SC_PWM4_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PWM4_Init write here*/	
}
/*****************************************************
*????????: SC_INT_Init
*????????: INT?????????
*????????void
*?????????void
*****************************************************/
void SC_INT_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*INT_Init write here*/	
}

/*****************************************************
*????????: SC_ADC_Init
*????????: ADC?????????
*????????void
*?????????void 
*****************************************************/
void SC_ADC_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*ADC_Init write here*/
}

/*****************************************************
*????????: SC_PGA_Init
*????????: PGA?????????
*????????void
*?????????void 
*****************************************************/
void SC_PGA_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PGA_Init write here*/
}

/*****************************************************
*????????: SC_IAP_Init
*????????: IAP?????????
*????????void
*?????????void 
*****************************************************/
void SC_IAP_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*IAP_Init write here*/		
}

/*****************************************************
*????????: SC_USCI0_Init
*????????: USCI0?????????
*????????void
*?????????void
*****************************************************/
void SC_USCI0_Init(void)
{
	//Forbid editing areas before the following label !!!
	GPIO_Init(GPIO0, GPIO_PIN_5,GPIO_MODE_IN_PU);
	GPIO_Init(GPIO0, GPIO_PIN_6,GPIO_MODE_IN_PU);
	USCI0_ITConfig(ENABLE,LOW);
	USCI0_UART_Init(32000000,115200,USCI0_UART_Mode_10B,USCI0_UART_RX_ENABLE);
	/*USCI0_Init write here*/		
}

/*****************************************************
*????????: SC_USCI1_Init
*????????: USCI1?????????
*????????void
*?????????void
*****************************************************/
void SC_USCI1_Init(void)
{
	//Forbid editing areas before the following label !!!
	//GPIO_Init(GPIO1, GPIO_PIN_1,GPIO_MODE_IN_PU);
	GPIO_Init(GPIO1, GPIO_PIN_3,GPIO_MODE_IN_PU);
	USCI1_ITConfig(ENABLE,LOW);
	//USCI1_UART_Init(32000000,  115200,  USCI1_UART_Mode_10B,USCI1_UART_RX_ENABLE);
	USCI1_UART_Init(32000000,  115200,  USCI1_UART_Mode_10B,USCI1_UART_RX_DISABLE);
	/*USCI1_Init write here*/		
}

/*****************************************************
*????????: SC_USCI2_Init
*????????: USCI2?????????
*????????void
*?????????void
*****************************************************/
void SC_USCI2_Init(void)
{
	//Forbid editing areas before the following label !!!
	GPIO_Init(GPIO4, GPIO_PIN_5,GPIO_MODE_IN_PU);
	GPIO_Init(GPIO4, GPIO_PIN_4,GPIO_MODE_IN_PU);
	USCI2_ITConfig(ENABLE,LOW);
	USCI2_UART_Init(32000000,9600,USCI2_UART_Mode_10B,USCI0_UART_RX_ENABLE);
	/*USCI2_Init write here*/		
}

/*****************************************************
*????????: SC_USCI3_Init
*????????: USCI3?????????
*????????void
*?????????void
*****************************************************/
void SC_USCI3_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*USCI3_Init write here*/		
}

/*****************************************************
*????????: SC_USCI4_Init
*????????: USCI4?????????
*????????void
*?????????void
*****************************************************/
void SC_USCI4_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*USCI4_Init write here*/		
}

/*****************************************************
*????????: SC_USCI5_Init
*????????: USCI5?????????
*????????void
*?????????void
*****************************************************/
void SC_USCI5_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*USCI5_Init write here*/		
}

/*****************************************************
*????????: SC_SSI_Init
*????????: SSI?????????
*????????void
*?????????void
*****************************************************/
void SC_SSI_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*SSI_Init write here*/		
}

/*****************************************************
*????????: SC_SSI0_Init
*????????: SSI?????????
*????????void
*?????????void
*****************************************************/
void SC_SSI0_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*SSI0_Init write here*/		
}

/*****************************************************
*????????: SC_SSI1_Init
*????????: SSI?????????
*????????void
*?????????void
*****************************************************/
void SC_SSI1_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*SSI1_Init write here*/		
}

/*****************************************************
*????????: SC_BTM_Init
*????????: ???????????????????
*????????void
*?????????void 
*****************************************************/
void SC_BTM_Init(void)
{
	//Forbid editing areas before the following label !!!
	BTM_Init(BTM_TIMEBASE_1S);
	BTM_ITConfig(ENABLE,LOW);
	BTM_Cmd(ENABLE); 		
}

/*****************************************************
*????????: SC_CRC_Init
*????????: check sum ?????????
*????????void
*?????????void
*****************************************************/
void SC_CRC_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*CRC_Init write here*/	
}

/*****************************************************
*????????: SC_CHKSUM_Init
*????????: check sum ?????????
*????????void
*?????????void
*****************************************************/
void SC_CHKSUM_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*CHKSUM_Init write here*/	
}

/*****************************************************
*????????: SC_WDT_Init
*????????: ??????????????
*????????void
*?????????void 
*****************************************************/
void SC_WDT_Init(void)
{
	//Forbid editing areas before the following label !!!
	WDT_Init(WDT_OverflowTime_500MS);
	OPTION_WDT_Cmd(ENABLE);
	/*WDT_Init write here*/		
}

/*****************************************************
*????????: SC_PWR_Init
*????????: ???/???????????????
*????????void
*?????????void 
*****************************************************/
void SC_PWR_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*PWR_Init write here*/		
}
/*****************************************************
*????????: SC_DDIC_Init
*????????: ???????????????
*????????void
*?????????void 
*****************************************************/
void SC_DDIC_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*DDIC_Init write here*/	
}

/*****************************************************
*????????: SC_ACMP_Init
*????????: ???????????
*????????void
*?????????void 
*****************************************************/
void SC_ACMP_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*ACMP_Init write here*/	
}

/*****************************************************
*????????: SC_MDU_Init
*????????: ????????????????
*????????void
*?????????void 
*****************************************************/
void SC_MDU_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*MDU_Init write here*/	
}

/*****************************************************
*????????: SC_LPD_Init
*????????: LPD?????????
*????????void
*?????????void 
*****************************************************/
void SC_LPD_Init(void)
{
	//Forbid editing areas before the following label !!!
	/*LPD_Init write here*/
}
